/**
 * Created by enixjin on 3/10/17.
 */
import {AbstractControl, ValidatorFn} from "@angular/forms";

export function ForbiddenNameValidator(nameRe: RegExp): ValidatorFn {
    return (control: AbstractControl): { [key: string]: any } => {
        const name = control.value;
        const no = nameRe.test(name);
        return no ? {'forbiddenName': {name}} : null;
    };
}
